/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

//1导入
import java.util.Calendar;
import java.util.Date;

/**
 * <p>Project: jse2204 - D2
 * <p>Powered by webrx On 2022-08-30 17:19:46
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class D2 {
    public static void main(String[] args) {

        //2实例化
        //var d = new Date();
        //System.out.printf("%tF %<tT%n",d);

        //var d5 = new Date(d.getTime() + (1000 * 60 * 60 * 24 * 10));
        //System.out.printf("%tF %<tT%n",d5);



        //3使用Date类实例获取当前的系统时间戳 long
        //System.out.println(d.getTime());
        //System.out.println(System.currentTimeMillis());

        //System.out.println(d.getYear()+1900);
        //System.out.println(d.getMonth()+1);
        //d.setTime(Long.MAX_VALUE);
        //System.out.printf("%tF %<tT%n",d);



        //日历
        //var c = Calendar.getInstance();
        //System.out.println(c.get(Calendar.YEAR));
        //System.out.println(c.get(Calendar.MONTH)+1);

        //日历类 转换为Date类
        //Date dd = c.getTime();

        //当前日历是由Date 类dd转换过来的
        //c.setTime(dd);

        //学生 1985-3-6  - now 活多少天
        var c1 = Calendar.getInstance(); //now
        c1.set(1985,3-1,6);
        System.out.printf("%tF %<tT%n",c1);
        int y1 = c1.get(Calendar.YEAR);

        long days = System.currentTimeMillis() - c1.getTimeInMillis();
        long ddd = days / (1000 * 60 * 60 * 24 );
        System.out.println(ddd);

        //多少年
        var c2 = Calendar.getInstance();
        c2.setTimeInMillis(System.currentTimeMillis());
        int y2 = c2.get(Calendar.YEAR);
        System.out.println(y2-y1);


    }
}
